<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * @extracolumn hook
 */
function hello1($data){
    return "?id=".$data["created_timestamp"]."&filterEvent=".$_REQUEST["filterEvent"];
}

$eventID = @$_REQUEST["filterEvent"];
$dropdown = "<select name='filterEvent' id='filterEvent' onchange='submitForm();'> <option value=''>-- select all --</option> ";
foreach ($eventListArr as $keyy => $val) {
    if (trim($eventID) == trim($val["id"])) {
        $selected = 'selected="selected"';
    } else {
        $selected = '';
    }
    $dropdown .= '<option value="' . $val["id"] . '" ' . $selected . '>' . $val["eventName"] . '</option>';
} 

if ($_POST['unit'] == 'inch') {
    $iSelected = 'selected="selected"';
    $uSelected = '';
} else if ($_POST['unit'] == 'cms') {
    $iSelected = '';
    $uSelected = 'selected="selected"';
}
$unit = '<select name="unit" id="unit">
            <option value="inch" ' . $iSelected . '>inch</option>
            <option value="cms" '.$uSelected.'>cms</option>
        </select>';

$sizeDropdown = "<select name='badgeSize' id='badgeSize' onchange='submitForm();'> <option value=''>-- select size --</option> ";
$bagdeSize = @$_REQUEST['badgeSize']; 
$sizeArray = array("3.35x2.16","3.5x2","3.58x2.16","3.37x2.12","3.54x1.96");
             foreach ($sizeArray as $key => $value) {
                if (trim($bagdeSize) == trim($sizeArray[$key])) {
                    $selected = 'selected="selected"';
                } else {
                    $selected = '';
                  }
                $sizeDropdown .= '<option value="' . $sizeArray[$key] . '" ' . $selected . '>' . $sizeArray[$key]." inch" . '</option>'; 
              }
$sizeDropdown .= "</select>";
/**
 * @desc : Record per page Dropdown
 */
$rPerPage = array('50','100') ;
$r_p_p = $_REQUEST["r_p_p"];
$recordPerPage = "<select name='r_p_p' id='r_p_p' onchange='submitForm();'> 
    <option value='10' selected='selected'>10</option> ";
foreach ($rPerPage as $keyy => $val) {
    if (trim($val) == trim($r_p_p)) {
        $selecteds = 'selected="selected"';
    } else {
        $selecteds = '';
    }
    $recordPerPage .= '<option value="' . $val. '" ' . $selecteds . '>' . $val. '</option>';
}
$recordPerPage .='</select>';

if (@$_SESSION["success_message"] != '') {
    $message = $_SESSION["success_message"];
    $style = "color:green";
} else if (@$_SESSION["error_message"] != '') {
    $message = $_SESSION["error_message"];
    $style = "color:red";
}
if($_POST || $eventID != '') {
    $dobj = new dbconnect();
    $dobj->dbconnect();
    $tableName = "lead,user,badgecategorymst";

    $tableDisplayField = array("first_name",
        "last_name",
        "address",
        "city",
        "state",
        "zipCode",
        "email",
        "BadgeCategoryName"
    );
    $tableDisplayFieldTitle = array("First Name",
        "Last Name",
        "Address",
        "City",
        "State",
        "Zipcode",
        "Email",
        "Badge Category",
    );

    $databaseFetchField = array("user.id",
        "badgecategorymst.BadgeCategoryName",
        "user.first_name",
        "user.last_name",
        "user.address",
        "user.city",
        "user.state",
        "user.zipCode",
        "user.email",
        "lead.created_timestamp"
    );
    if(@$_REQUEST["r_p_p"] != '') {
        $recordPerPages = @$_REQUEST["r_p_p"];
    } else {
        $recordPerPages = '10';
    }
    $beforeWhereCondition = "  ";
    
    $extraColumnField = array(array("referenceField"=> "first_name",
                                  "newField" =>"created_timestamp",
                                  "referenceFieldTitle" =>"First Name",
                                  "newFieldTitle"=> "Complete Address" ,  
                                  "referenceFieldValueHook"=>'hello',
                                  "position"=>"before"
                                ),
                                array("referenceField"=> "last_name",
                                  "newField" =>"created_timestamp",
                                  "referenceFieldTitle" =>"Last Name",
                                  "newFieldTitle"=> "Complete Address" ,  
                                  "referenceFieldValueHook"=>'hello',
                                  "position"=>"after"
                                )
                            );
    $afterWhereConditon = "AND 
                            lead.created_timestamp = user.created_timestamp AND 
                            lead.BCM_ID = badgecategorymst.BCM_ID AND 
                            lead.user_id = '" . $_SESSION['MAA_ID'] . "' && 
                            lead.event_id = '$eventID'";
    $primarykey = 'created_timestamp';
    $css = array("width" => "98%");
    $editUrl = "editattendee.php";
    $msg ="No such attendees found for this event.";
    $pageName = "printbadge.php";
    $extraUrlPara = "filterEvent=".$eventID."&r_p_p=".$recordPerPages;
    $pagingArray_1 = array("dbTableName" => $tableName,
        "tableDisplayField" => $tableDisplayField,
        "tableDisplayFieldTitle" => $tableDisplayFieldTitle,
        "databaseFetchField" => $databaseFetchField,
        "pageName" => $pageName,
        "recordPerPage" => $recordPerPages,
        "noOfLink" => "3",
        "joinStatus" => '1',
        "beforeWhereCondition" => $beforeWhereCondition,
        "afterWhereCondition" => $afterWhereConditon,
        "activeStatus" => 1,
        "deleteStatus" => 1,
        "editStatus" => 1,
         "editPageUrl"=>$editUrl,
         /* "editHook" => $editpara, */
        "primarykeyFieldName" => $primarykey,
        "debugQuery" => 0,
        "searchPanel" => 0,
        "css" => $css,
        "extraLink" => array(
                            array(  "name"=>"Edit" ,
                                    "url"=>"editAttendee.php",
                                    "qstringHook"=>"hello1"
                                )
                                
                        ),
        "defaultMessage" => $msg,
        "actionColumn" => True,
        "extraColumnStatus" =>0,
        "extraColumnArray" =>""
    );

    $pg = new Magic_CreatePagin_Model();
}

//echo json_encode($pagingArray_1);
?>


<div id="inner-page">
    <div class="inner-main">
        <div class="inner-strip"><h2>Print Attendee's Badges</h2></div>
    </div>

</div>
<form id="leadForm" name="leadForm" id="myform" action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="actionPanelVar" id="actionPanelVar" />
   
    <div class="midwork">
        <div class="inner-page-table">
            <div class="inner-page-table" style="margin: 12px 0 0;">

                <div style="padding: 5px;text-align: center;font-size: larger;<?php echo $style; ?>">
<?php echo $message;
unset($_SESSION["error_message"]);
unset($_SESSION["success_message"]); ?>
                </div>
                <div id="action-panel">
                    <div class="panel-child">
                        <div style='float:left;width:920px;margin:5px 0;'>
                            <a href="javascript:void(0);" onclick="CheckAll(document.leadForm.chk,'checked');">Check All</a>&nbsp;|&nbsp;
                            <a href="javascript:void(0);" onclick="CheckAll(document.leadForm.chk);">Uncheck All</a>&nbsp;|&nbsp;
                            Record Per Page : <?php echo $recordPerPage; ?>&nbsp;|&nbsp;
                            
                            Select Event <?php echo $dropdown; ?>
                        
                         <input type="button" class="but" onclick="printBadge();" value="Print Badges">&nbsp;|&nbsp;
                         <a href="javascript:void(0);" onclick="showAdvanced();">Advance <span id="plus">(+)</span></a>
                           </div>
                    </div>
                </div>
                <br />
                 
                <div id="action-panel" class="advanced" style="display:none ">
                    <div class="panel-child">
                        <div style='float:left;width:920px;margin:5px 0;'>
                            
                            
                          Select Size:<?php echo $sizeDropdown;?> &nbsp;&nbsp;
                          
                          Upload Logo: <input type="file" name="printbadge_logo" id="logo"></input>&nbsp;&nbsp;
                           
                        </div>
                        
                    </div>
                </div>
               <br />
<?php if($_POST || $eventID != '') {echo $pg->createPaging($pagingArray_1);} ?>

            </div>

        </div>

    </div>
</div>
</form>    
